package js.web.center.netty.code;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import js.web.center.netty.entity.JsWebSocketBaseProtocol;
/**
 * socket编码器
 * @author qpduw
 *
 */
public class JsWebSocketEncoder extends MessageToByteEncoder<JsWebSocketBaseProtocol> {

	@Override
	protected void encode(ChannelHandlerContext channel, JsWebSocketBaseProtocol protocol, ByteBuf buf) throws Exception {
		buf.writeInt(protocol.getHeadData());
		buf.writeInt(protocol.getContentLength());
		buf.writeBytes(protocol.getContent());
	}
}
